<template>
  <TopMenu/>
  <div class="container event-details">
    <div class="left-side">
      <div class="left-side-item" :class="currentTabIndex == index ? 'active': ''"
           v-for="(evt,index) in eventContents"
           :key="`evt${index}`" @click="changeTab(index)">{{evt.themeTitle}}</div>
    </div>
    <section class="_content" v-if="eventContents.length">
      <div class="evtContent" v-html="eventContents[currentTabIndex].themeContent"></div>
    </section>
    <section class="_brands">
      <img class="brandImg" v-for="(item, index) in brandList" :key="`img_${index}`" :src="item.image"/>
    </section>
  </div>
</template>

<script setup>
import TopMenu from '@/components/TopMenu/index.vue'
import { eventData } from '@/api/data.js'
import { useRoute } from 'vue-router'
import { useEventStore } from '@/stores/event/index.js'
const $route = useRoute()
const eventStore = useEventStore()
// 品牌列表数据
const brandList = ref([])
const currentTabIndex = ref($route.query.type || 0)
// 赛事内容
const eventContents = ref([]);
const changeTab = (index) => {
  currentTabIndex.value = index
}
const getEventData = () => {
  const eventId = $route.query.evtId || 5
  eventData(eventId).then((res) => {
    if (res.code == 200) {
      eventContents.value = res.data.evt.contents;
      brandList.value = res.data.partners;
      eventStore.setCurrentEventData(res.data.evt);
    }
  })
}
onMounted(() => {
  getEventData()
})
</script>

<style scoped lang="scss">
.event-details {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 30px;
  ._content {
    flex: 1;
    .content-tabs {
      margin-top: 10px;
      display: flex;
      align-items: center;
      gap: 20px;
      justify-content: space-between;
      border-top: 1px solid #e8e8e8;
      padding-top: 30px;
      .tabItems {
        font-size: 22px;
        font-weight: 400;
        cursor: pointer;
        position: relative;
        &:hover {
          color: #5F3789;
          &::after {
            content: "";
            position: absolute;
            left: 0;
            width: 100%;
            height: 4px;
            border-radius: 4px;
            background: #5F3789;
            top: calc(100% + 15px);
          }
        }
      }
      .active {
        &::after {
          content: "";
          position: absolute;
          left: 0;
          width: 100%;
          height: 4px;
          border-radius: 4px;
          background: #5F3789;
          top: calc(100% + 15px);
        }
      }
    }
    .evtContent {
      padding: 20px;
      line-height: 1.8;
    }
  }
  ._brands {
    width: 100px;
    height: 500px;
    overflow: scroll;
    display: flex;
    flex-direction: column;
    .brandImg {
      width: 100%;
      height: 80px;
      object-fit: contain;
    }
  }
}
</style>
